package main

import (
	"ginEssential/controller"
	"ginEssential/middleware"
	"github.com/gin-gonic/gin"
)

func CollectRouter(r *gin.Engine) *gin.Engine {
	r.POST("/api/auth/register", controller.Register)
	r.POST("/api/auth/login", controller.Login)
	r.GET("/api/auth/info", middleware.AuthMiddleware(), controller.Info)

	categoryRoutes := r.Group("/categories")
	categoryController := controller.NewCategoryController()
	categoryRoutes.POST("", categoryController.Create)
	categoryRoutes.PUT("/:id", categoryController.Update)
	categoryRoutes.GET("/:id", categoryController.Show)
	categoryRoutes.DELETE("/:id", categoryController.Delete)

	roleRouters := r.Group("/roles")
	roleController := controller.NewRoleController()
	roleRouters.POST("", roleController.Create)
	roleRouters.PUT("/:id", roleController.Update)
	roleRouters.GET("/:id", roleController.Show)
	roleRouters.DELETE("/:id", roleController.Delete)

	departmentRouters := r.Group("/department")
	departmentController := controller.NewDepartmentController()
	departmentRouters.POST("", departmentController.Create)
	departmentRouters.PUT("/:id", departmentController.Update)
	departmentRouters.GET("/:id", departmentController.Show)
	departmentRouters.DELETE("/:id", departmentController.Delete)

	return r
}
